<?php

$event = $this->event;

foreach($this->vote_info as $thread_id=>$thread){
    if(count($thread) >= 1){
        foreach($thread as $phase_id=>$phase){         
            $voteImgArr = array();
            if($phase->view_enable ==1 && isset($this->imgList[$phase->thid][$phase->pid])
            && is_array($this->imgList[$phase->thid][$phase->pid]) 
            && count($this->imgList[$phase->thid][$phase->pid])>0
            && $phase->vote_type == EVENT_PHOTO_VOTE){
                $voteImgArr = $this->imgList[$phase->thid][$phase->pid];

                $photo_block_id = $thread_id."_".$phase_id;
                $photo_block_title = $phase->thread_name.($phase->phase_name != ""?" - ".$phase->phase_name:"");
                $bgImg = "header-small-".$thread_id.'-'.$phase_id.".png";
?>
                    <!--Photo:-->
                    <a name="mark_photo_<?=$photo_block_id?>"></a>
                    <div id="photo" class="event-area block-in">
                        <div class="event-header-long">
                            <?php
                            $href = "/event/".$event->short_cut."/votedlist/".$thread_id."/".$phase_id;
                            if($phase->votephoto_category > 0){
                                $href = 'http://photo.tamtay.vn/category/browse/'.$phase->votephoto_category;
                            }
                                
                            ?>
                            <span class="value">
				                <a href="<?=$href?>" title="<?=$photo_block_title?>">
					                <?=$photo_block_title;?>
					                <!--<img alt="<?=$photo_block_title?>" src="<?php echo $this->spath;?>/images/<?=$bgImg?>">-->
				                </a>
                            </span>      
                        </div>
                        <div class="hde png">
                           <table width="100%" cellpadding="0" cellspacing="0">
                              <tr>
                                 <td width="50%"><div class="hde_1">
                                       <div class="de_0_1"></div>
                                    </div></td>
                                 <td width="50%"><div class="hde_2">
                                       <div class="de_0_1"></div>
                                    </div></td>
                              </tr>
                           </table>
                        </div>
                        <div class="event-content-long" style="padding-left:40px;">
                            <!--Photo Content-->
                            <?php if(is_array($voteImgArr) && count($voteImgArr)>0){?>
                            <ul class="photo-group" style="margin-top:10px;">
                            <?php 
                                for($i=0; $i<count($voteImgArr) && $i<4; $i++){
                                    $imgObj = $voteImgArr[$i];
                                    $thumbnail = (isset($imgObj->img_server)?'http://img'.($imgObj->img_server != 1?$imgObj->img_server:'').'.tamtay.vn/':EVENT_IMG_SERVER2).$imgObj->thumbnail;
                                ?>
                                <li class="photo-item">
                                    <div class="wrapEventNew01" style="float:left; margin-bottom: 5px;">
                                        <div class="wrapEventNew02">
                                            <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                                <img src="<?=$thumbnail;?>"  onload="resizeImage(this,125, 100)" />
                                            </a>
                                        </div>
                                    </div>
                                    <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                        <?php echo $imgObj->album_name;?>
                                    </a>
                                </li>
                            <?php 
                                }    // End of for
                            ?>
                            </ul>
                            <?php } // End of if?>
                            <?php if(is_array($voteImgArr) && count($voteImgArr)>4){?>
                            <ul class="photo-group">
                            <?php 
                                for($i=4; $i<count($voteImgArr) && $i<8; $i++){
                                    $imgObj = $voteImgArr[$i];
                                    $thumbnail = (isset($imgObj->img_server)?'http://img'.($imgObj->img_server != 1?$imgObj->img_server:'').'.tamtay.vn/':EVENT_IMG_SERVER2).$imgObj->thumbnail;
                                ?>
                                <li class="photo-item<?php echo $i==4?" clear-left":""; ?>">
                                    <div class="wrapEventNew01" style="float:left; margin-bottom: 5px;">
                                        <div class="wrapEventNew02">
                                            <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                                <img src="<?=$thumbnail;?>" onload="resizeImage(this,125, 100)" />
                                            </a>
                                        </div>
                                    </div>
                                    <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                        <?php echo $imgObj->album_name;?>
                                    </a>
                                </li>
                            <?php 
                                } // End of for
                            ?>
                            </ul>
                                
                            <?php } // End of if?>
                            <?php if(is_array($voteImgArr) && count($voteImgArr)>8){?>
                            <ul class="photo-group">
                            <?php 
                                for($i=8; $i<count($voteImgArr) && $i<12; $i++){
                                    $imgObj = $voteImgArr[$i];
                                    $thumbnail = (isset($imgObj->img_server)?'http://img'.($imgObj->img_server != 1?$imgObj->img_server:'').'.tamtay.vn/':EVENT_IMG_SERVER2).$imgObj->thumbnail;
                                ?>
                                <li class="photo-item<?php echo $i==8?" clear-left":""; ?>">
                                    <div class="wrapEventNew01" style="float:left; margin-bottom: 5px;">
                                        <div class="wrapEventNew02">
                                            <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                                <img src="<?=$thumbnail;?>" onload="resizeImage(this,125, 100)" />
                                            </a>
                                        </div>
                                    </div>
                                    <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                        <?php echo $imgObj->album_name;?>
                                    </a>
                                </li>
                            <?php 
                                } // End of for
                            ?>
                            </ul>
                                
                            <?php } // End of if?>
                            <?php if(is_array($voteImgArr) && count($voteImgArr)>12){?>
                            <ul class="photo-group">
                            <?php 
                                for($i=12; $i<count($voteImgArr) && $i<16; $i++){
                                    $imgObj = $voteImgArr[$i];
                                    $thumbnail = (isset($imgObj->img_server)?'http://img'.($imgObj->img_server != 1?$imgObj->img_server:'').'.tamtay.vn/':EVENT_IMG_SERVER2).$imgObj->thumbnail;
                                ?>
                                <li class="photo-item<?php echo $i==12?" clear-left":""; ?>">
                                    <div class="wrapEventNew01" style="float:left; margin-bottom: 5px;">
                                        <div class="wrapEventNew02">
                                            <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                                <img src="<?=$thumbnail;?>" onload="resizeImage(this,125, 100)" />
                                            </a>
                                        </div>
                                    </div>
                                    <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                        <?php echo $imgObj->album_name;?>
                                    </a>
                                </li>
                            <?php 
                                } // End of for
                            ?>
                            </ul>
                                
                            <?php } // End of if?>
                            <?php if(is_array($voteImgArr) && count($voteImgArr)>16){?>
                            <ul class="photo-group">
                            <?php 
                                for($i=16; $i<count($voteImgArr) && $i<20; $i++){
                                    $imgObj = $voteImgArr[$i];
                                    $thumbnail = (isset($imgObj->img_server)?'http://img'.($imgObj->img_server != 1?$imgObj->img_server:'').'.tamtay.vn/':EVENT_IMG_SERVER2).$imgObj->thumbnail;
                                ?>
                                <li class="photo-item<?php echo $i==16?" clear-left":""; ?>">
                                    <div class="wrapEventNew01" style="float:left; margin-bottom: 5px;">
                                        <div class="wrapEventNew02">
                                            <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                                <img src="<?=$thumbnail?>" onload="resizeImage(this,125, 100)" />
                                            </a>
                                        </div>
                                    </div>
                                    <a href="http://photo.tamtay.vn/photo/view/<?php echo $imgObj->aid;?>" target="_blank">
                                        <?php echo $imgObj->album_name;?>
                                    </a>
                                </li>
                            <?php 
                                } // End of for
                            ?>
                            </ul>
                                
                            
                            <?php } ?>
                            <div class="clear"></div>

                            <!--End Photo Content-->
                            <div class="text-right viewmore"><a href="<?php
                                if($phase->votephoto_category > 0)
                                    echo 'http://photo.tamtay.vn/category/browse/'.$phase->votephoto_category;
                                else 
                                    echo "/event/".$event->short_cut."/votedlist/".$thread_id."/".$phase_id;
                                    ?>">Xem tiếp &raquo;</a></div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <!--End photo-->
                
<?php 
            }
        }
    }
    
} ?>